import React from 'react';
import {
  Dimensions,
  Image,
  ImageBackground,
  StyleSheet,
  Text,
  View,
} from 'react-native';
import ImageConstants from '../resources/ImageConstants';
import Video, {VideoRef} from 'react-native-video';

const WIN_WIDTH = Dimensions.get('window').width;

//系统设置
class CabinetVideoPage extends React.Component<any> {
  constructor(props) {
    super(props);
    this.state = {};
    console.log(props.route.params);
  }

  render() {
    console.log(this.props.route.params);
    return (
      <View style={{flex: 1, width: '100%', justifyContent: 'center'}}>
        <ImageBackground
          source={ImageConstants.ICON_VIDEO_BACKGROUND}
          style={{width: '100%', height: '100%', justifyContent: 'center'}}>
          <Video
            // Can be a URL or a local file.
            source={{
              uri: this.props.route.params.data.filePath,
            }}
            resizeMode="stretch"
            controls={true}
            paused={false}
            // Store reference
            style={{
              width: WIN_WIDTH,
              height: WIN_WIDTH * 0.7,
              marginBottom: '3.5%',
              backgroundColor: 'black',
            }}
            onError={error => {
              console.log(error);
            }}
          />
          <Text style={{margin: 15, fontSize: 25, color: 'white'}}>
            {this.props.route.params.data.newsName}
          </Text>
        </ImageBackground>
      </View>
    );
  }
}

const styles = StyleSheet.create({});
export default CabinetVideoPage;
